home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS19.ADF
/
Progs
/
WinSize
/
WinSize.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-01-27
|
3KB
|
102 lines
/*************************************************************************
*
* WinSize - a window sizing utility
*
* Copyright ⌐ 1987 by
* Limited Reality, Inc.
*
************************************************************************/
#include <exec/types.h>
#include <intuition/intuitionbase.h>
#include <stdio.h>
#ifdef stdout
#undef stdout
#endif
FILE *stdout;
struct IntuitionBase *IntuitionBase = 0;
main(argc, argv)
int argc;
char *argv[];
{
int width = 9999, height = 9999, left = -1, top = -1;
stdout = (FILE *)Output();
if ((argc == 2) && (argv[1][0] == '?')) {
printf("Usage: %s [leftedge topedge width height]\n",argv[0]);
exit(0);
}
if ((argc != 1) && (argc != 5)) {
puts("Bad ARGS");
exit(0);
}
if ((IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 0)) == 0) {
exit(20);
}
if (argc == 5) {
left = atoi(argv[1]);
top = atoi(argv[2]);
width = atoi(argv[3]);
height = atoi(argv[4]);
}
if (width > IntuitionBase->ActiveScreen->Width)
width = IntuitionBase->ActiveScreen->Width;
if (width > IntuitionBase->ActiveWindow->MaxWidth)
IntuitionBase->ActiveWindow->MaxWidth = width;
if (width < IntuitionBase->ActiveWindow->MinWidth)
width = IntuitionBase->ActiveWindow->MinWidth;
if (height > IntuitionBase->ActiveScreen->Height)
height = IntuitionBase->ActiveScreen->Height;
if (height > IntuitionBase->ActiveWindow->MaxHeight)
IntuitionBase->ActiveWindow->MaxHeight = height;
if (height < IntuitionBase->ActiveWindow->MinHeight)
height = IntuitionBase->ActiveWindow->MinHeight;
if (left < 0) left = 0;
if (top < 0) top = 0;
if (left > (IntuitionBase->ActiveScreen->Width - width))
left = (IntuitionBase->ActiveScreen->Width - width);
if (top > (IntuitionBase->ActiveScreen->Height - height))
top = (IntuitionBase->ActiveScreen->Height - height);
if ((left < IntuitionBase->ActiveWindow->LeftEdge) ||
(top < IntuitionBase->ActiveWindow->TopEdge)) {
MoveWindow(IntuitionBase->ActiveWindow,
left-IntuitionBase->ActiveWindow->LeftEdge,
top-IntuitionBase->ActiveWindow->TopEdge);
SizeWindow(IntuitionBase->ActiveWindow,
width-IntuitionBase->ActiveWindow->Width,
height-IntuitionBase->ActiveWindow->Height);
} else {
SizeWindow(IntuitionBase->ActiveWindow,
width-IntuitionBase->ActiveWindow->Width,
height-IntuitionBase->ActiveWindow->Height);
MoveWindow(IntuitionBase->ActiveWindow,
left-IntuitionBase->ActiveWindow->LeftEdge,
top-IntuitionBase->ActiveWindow->TopEdge);
}
RethinkDisplay();
CloseLibrary(IntuitionBase);
}